<template>
  <div class="bsd-frame" id="bsdFrame" ref="bsdFrame">
    <div
      class="hrader"
      style="height: 10%; width: 100%; background-color: aliceblue"
    ></div>
    <div class="content" ref="bsdContent">
      <div class="content-item content_left">
        <div class="left_top">
          <div class="echart_content" id="echart_content"></div>
        </div>
        <div class="left_center"></div>
        <div class="left_bottom"></div>
      </div>
      <div class="content-item content_center">
        <map-container></map-container>
        <seacher></seacher>
        <heat-map-search-box></heat-map-search-box>
      </div>
      <div class="content-item content_right"></div>
    </div>
  </div>
</template>
  
  <script>
import * as echarts from "echarts";
import MapContainer from "../components/MapContainer.vue";
import Seacher from "../components/Seacher.vue";
import HeatMapSearchBox from "../components/HeatMapSearchBox.vue";
export default {
  components: {
    MapContainer,
    Seacher,
    HeatMapSearchBox,
  },
  data() {
    return {
      frameWidth: 0,
      frameHeight: 0,
    };
  },
  mounted() {
    this.setSize();
    this.setScale();
    window.addEventListener("resize", this.setScale);
    this.initSevenRefuse();
  },
  destroyed() {
    window.removeEventListener("resize", this.setScale);
  },
  methods: {
    setSize() {
      this.frameWidth = window.screen.width;
      this.frameHeight = window.screen.height;
      const frame = this.$refs.bsdFrame; //为容器根元素设置宽高
      frame.style.width = this.frameWidth + "px";
      frame.style.height = this.frameHeight + "px";
    },
    setScale() {
      const bodyWidth = document.documentElement.clientWidth; //前提是html,body的height: 100%; width: 100%
      const bodyHeight = document.documentElement.clientHeight;
      const scaleX = bodyWidth / this.frameWidth;
      const scaleY = bodyHeight / this.frameHeight;
      this.$refs.bsdFrame.style.transform = `scale(${scaleX},${scaleY})`;
    },
    // 七天垃圾趋势图
    initSevenRefuse() {
      var chartDom = document.getElementById("echart_content");
      var myChart = echarts.init(chartDom);
      var option;
      option = {
        xAxis: {
          type: "category",
          boundaryGap: false,
          data: ["11日", "12日", "13日", "14日", "15日", "16日", "17日"],
        },
        yAxis: {
          type: "value",
          splitLine: {
            show: true,
            lineStyle: {
              opacity: 0.2,
              color: ["#929191"],
            },
          },
        },
        legend: {
          show: true,
          bottom: 30,
          textStyle: {
            color: "#fff",
          },
          data: ["焚烧厂", "中转站"],
        },
        grid: {
          left: "3%",
          right: "4%",
          top: "14%",
          // bottom: "25%",
          containLabel: true,
        },
        series: [
          {
            data: [820, 932, 901, 934, 290, 330, 320],
            type: "line",
            name: "焚烧厂",
            smooth: true,
            lineStyle: {
              // 设置线条的style等
              normal: {
                color: "#228F96", // 折线线条颜色:红色
              },
            },
            areaStyle: {
              color: "#228F96",
            },
          },
          {
            data: [620, 332, 901, 634, 690, 330, 520],
            type: "line",
            name: "中转站",
            smooth: true,
            lineStyle: {
              // 设置线条的style等
              normal: {
                color: "#305694", // 折线线条颜色:红色
              },
            },
            areaStyle: {
              color: "#305694",
            },
          },
        ],
      };
      option && myChart.setOption(option);
    },
  },
};
</script>
  
  <style lang="scss" scoped>
.bsd-frame {
  background: url("@/assets/imgs/bigBG.jpg");
  background-size: 100% 100%;
  transform-origin: 0 0;
  display: flex;
  flex-direction: column;
  .content {
    flex: 1; /* 让内容div填充剩余空间 */
    display: flex;
    flex-direction: row;
    .content-item {
      width: 25%;
    }
    .content_center {
      width: 50%;
      position: relative;
    }
    .content_left {
      display: flex;
      flex-direction: column;
      div {
        flex: 1;
      }
      .left_top {
        .echart_content {
          width: 90%;
          margin: 0 auto;
          height: 200px;
        }
      }
      .left_center {
        flex: 1.3;
      }
    }
  }
}
.search {
  position: absolute;
  left: 0;
  top: 0;
}
.showHeatMap {
  position: absolute;
  left: 165px;
  top: 45px;
  background: #fff;
}
</style>